function initPowerChart() {
    var main = echarts.init(document.getElementById("main0"));
    getAjaxReq("statistics/totalPowerConsumeByDate", getParams(), function (res) {
        var option = {
            color:['#fb7d02','#5dafd9','#3b6894','#94dbfc','#61b1c6'],
            legend: {
                data: ['总值', '尖值', '峰值', '平值', '谷值']
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {type: 'cross'}
            },
            toolbox: {
                show: true,
                feature: {saveAsImage: true, restore: {show: true},}
            },
            grid: {y2: 140}
        }
        if (res.code == 1) {
            option.xAxis = [{
                type: 'category',
                data: res.data.xAxis,
                axisLabel: {rotate: 60}
            }]
            option.yAxis = [{
                type: 'value',
                name:'度数(千瓦时)',
                axisLabel: {
                    formatter: function (value) {
                        var length = value.toString().length
                        if (length > 5) {
                            value = value / 10000 + "万";
                        } else if (length >= 8) {
                            value = value / 10000000 + "千万";
                        } else if (length >= 10) {
                            value = value / 10000000 + "十亿";
                        }
                        return value;
                    }
                },
                axisPointer: {snap: true}
            }]
            option.series = [
                {
                    name: '总值',
                    type: 'bar',
                    data: res.data.yAxis.amount,
                    label: {show: true, position: 'top'}
                },
                {
                    name: '尖值',
                    type: 'bar',
                    stack: "尖值",
                    data: res.data.yAxis["cusp"],
                },
                {
                    name: '峰值',
                    type: 'bar',
                    stack: "尖值",
                    data: res.data.yAxis.flat,
                },
                {
                    name: '平值',
                    type: 'bar',
                    stack: "尖值",
                    data: res.data.yAxis["peak"],
                },
                {
                    name: '谷值',
                    type: 'bar',
                    stack: "尖值",
                    data: res.data.yAxis["valley"]
                }
            ]
            option.dataZoom = [{
                startValue: res.data.start,
                endValue: res.data.end,
                show: true
            }]
        } else {
            option.series = []
            main.clear()
        }
        main.setOption(option)
    })
}
var flag = true
function initRechargeChart() {
    var main1 = echarts.init(document.getElementById('main1'))
    if (flag) $("#main1").hide()
    getAjaxReq("statistics/totalRechargeApplyByDate", getParams(), function (res) {
        var option = {
            legend: {
                data: ['金额', '笔数']
            },
            tooltip: {trigger: 'axis'},
            toolbox: {
                show: true,
                right: "2%",
                feature: {restore: {show: true}}
            },
            calculable: true,
            grid: {y2: 140}
        }
        if (res.code == 1) {
            option.xAxis = [{
                type: 'category',
                data: res.data.xAxis,
                axisLabel: {rotate: 60}
            }]
            option.yAxis = [{
                name: "金额(元)",
                type: 'value',
                axisLabel: {
                    formatter: function (value) {
                        var length = value.toString().length
                        if (length > 5) {
                            value = value / 10000 + "万";
                        } else if (length >= 8) {
                            value = value / 10000000 + "千万";
                        } else if (length >= 10) {
                            value = value / 10000000 + "十亿";
                        }
                        return value;
                    }
                },
            }, {
                name: "笔数",
                type: 'value',
                axisLabel: {
                    formatter: function (value) {
                        var length = value.toString().length
                        if (length > 5) {
                            value = value / 10000 + "万";
                        } else if (length >= 8) {
                            value = value / 10000000 + "千万";
                        } else if (length >= 10) {
                            value = value / 10000000 + "十亿";
                        }
                        return value;
                    }
                }
            }]
            option.series = [{
                name: "金额",
                type: "line",
                color: ['#6db393'],
                data: res.data.yAxis['amount'],
                label: {show: true, position: 'top'}
            }, {
                name: "笔数",
                type: "line",
                color: ['#9b3e73'],
                data: res.data.yAxis['count'],
                yAxisIndex: 1,
                label: {show: true, position: 'top'}
            }]
            option.dataZoom = [{
                startValue: res.data.start,
                endValue: res.data.end,
                show: true
            }]
        } else {
            option.series = []
            main1.clear()
        }
        main1.setOption(option)
    })
}

initRechargeChart()
initPowerChart()
flag = false
